var assert = require('assert')

import {parseHtml} from '../src/parser'

describe('parse html:', ()=>{
  it('<a></a>', ()=>{
    let tree = parseHtml('<a></a>')
    assert.equal(tree.children[0].tagName, "a")
    assert.equal(tree.children[0].children.length, 0)
  })
  it('<a href="//baidu.com.cn"></a>', ()=>{
    let tree = parseHtml('<a href="//baidu.com.cn"></a>')
    assert.equal(tree.children.length, 1)
    assert.equal(tree.children[0].children.length, 0)
  })
  it('<a id=\'test\'></a>', ()=>{
    let tree = parseHtml('<a id=\'test\'></a>')
    assert.equal(tree.children.length, 1)
    assert.equal(tree.children[0].children.length, 0)
  })
  it('<a id=test></a>', ()=>{
    let tree = parseHtml('<a id=test></a>')
    assert.equal(tree.children.length, 1)
    assert.equal(tree.children[0].children.length, 0)
  })
  it('<a id=test />', ()=>{
    let tree = parseHtml('<a id=test />')
    assert.equal(tree.children.length, 1)
    assert.equal(tree.children[0].children.length, 0)
  })
  it('<a id="test" />', ()=>{
    let tree = parseHtml('<a id="test" />')
    assert.equal(tree.children.length, 1)
    assert.equal(tree.children[0].children.length, 0)
  })
  // it('<a id=\'test\' />', ()=>{
  //   let tree = parseHtml('<a \'test\' />')
  //   assert.equal(tree.children.length, 1)
  //   assert.equal(tree.children[0].children.length, 0)
  // })
  it('<a href="aa" ></a>', ()=>{
    let tree = parseHtml('<a href id></a>')
    assert.equal(tree.children.length, 1)
    assert.equal(tree.children[0].children.length, 0)
  })
  it('<a />', ()=>{
    let tree = parseHtml('<a />')
    assert.equal(tree.children.length, 1)
    assert.equal(tree.children[0].children.length, 0)
  })
  it('<A />upper case', ()=>{
    let tree = parseHtml('<A />upper case')
    assert.equal(tree.children[0].tagName,"A")
    assert.equal(tree.children[0].children.length, 0)
  })
  it('<a>', ()=>{
    let tree = parseHtml('<a>')
    assert.equal(tree.children.length, 1)
    // assert.equal(tree.children[0].type, 0)
  })
})